﻿import flash.external.*

ALL_ITEM_VIEWS = [itemview_0, itemview_1]

function buy_item(e:Object)
{
	ExternalInterface.call("td_itembar.buy_item", e.target.iJob);
}

for (i = 0; i< 2; i++)
{
	ALL_ITEM_VIEWS[i].btnBuy.iJob = i;
	ALL_ITEM_VIEWS[i].btnBuy.addEventListener("click", this, "buy_item");
}

function exit()
{
	ExternalInterface.call("td_itembar.exit");
}
btnClose.addEventListener("click", this, "exit");

function set_item_view(_index:Number, item_name:String, item_price:String, item_image:String, item_left:String)
{
	if (item_name.length > 0)
	{
		ALL_ITEM_VIEWS[_index]._visible = true;
		ALL_ITEM_VIEWS[_index].itemname.text = item_name;
		ALL_ITEM_VIEWS[_index].price.text = item_price;
		ALL_ITEM_VIEWS[_index].itemicon.source = item_image;
		ALL_ITEM_VIEWS[_index].itemleft.text = item_left;
	}
	else
	{
		ALL_ITEM_VIEWS[_index]._visible = false;
	}
}